﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class OrdersTypeDAL : PageDAL<OrdersTypeModel>
    {
        public DataTable DSelectID(string TableName, int ID)
        {
            string sql = $"select * from {TableName} where OrdersID={ID}";
            return new DBHelper().GetDataTable(sql);
        }
        public DataTable LJA(string Onename, string Twoname,int ID)
        {
            string sql = $"Select a.* , b.Name from {Onename} a,{Twoname} b where b.id = a.{Twoname}id and  OrdersID={ID}";
            return new DBHelper().GetDataTable(sql);
        }
        public OrdersTypeModel GetModelByID(string TableName, int id)
        {
            string sql = $"select * from  {TableName} where id='{id}'";
            DataTable dt = new DBHelper().GetDataTable(sql);
            OrdersTypeModel model = new OrdersTypeModel()
            {
                ID = int.Parse(dt.Rows[0]["id"].ToString()),
                OrdersID = int.Parse(dt.Rows[0]["OrdersID"].ToString()),
                Price = decimal.Parse(dt.Rows[0]["price"].ToString()),
                ShopID = int.Parse(dt.Rows[0]["ShopID"].ToString()),
                No = int.Parse(dt.Rows[0]["No"].ToString()),
                Remark = dt.Rows[0]["Remark"].ToString()
            };
            return model;
        }
    }
}
